package org.jawp.persistence;

public class Customer {

	// members
	private final int id;
	private Title title;
	private String firstName;
	private String lastName;
	private String adress;
	private String phone;
	private String email; //TODO unique
	
	// constructor
	public Customer(int id, Title title, String firstName, String lastName,
			String adress, String phone, String email) {
		super();
		this.id = id;
		this.title = title;
		this.firstName = firstName;
		this.lastName = lastName;
		this.adress = adress;
		this.phone = phone;
		this.email = email;
	}
	
	// getters

	public Title getTitle() {
		return title;
	}

	public String getFirstName() {
		return firstName;
	}

	public String getLastName() {
		return lastName;
	}

	public String getAdress() {
		return adress;
	}

	public String getPhone() {
		return phone;
	}

	public String getEmail() {
		return email;
	}

	public int getId() {
		return id;
	}
	
	// setters
	
	public void setTitle(String title) {
		this.title = Title.valueOf(title);
	}

	public void setFirstName(String firstName) {
		this.firstName = firstName;
	}

	public void setLastName(String lastName) {
		this.lastName = lastName;
	}

	public void setAdress(String adress) {
		this.adress = adress;
	}

	public void setPhone(String phone) {
		this.phone = phone;
	}

	public void setEmail(String email) {
		this.email = email;
	}
	
	// generic methods
	
	@Override
	public String toString() {
		return "Customer named "+title.getTitle()+" "+firstName+" "+lastName+"(id = "+id+")";
	}

	@Override
	public boolean equals(Object obj) {
		if( (obj instanceof Customer) && (this.id == ((Customer)obj).id))
			return true;
		return false;
	}
}
